/*
* Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:  Implementation of the ECom interface for NFC External
*               Content Handler interface.
*/

#include "contenthandler.h"
#include "messagehandler.h"

// ---------------------------------------------------------------------------
// Symbian two-phased constructor.
// ---------------------------------------------------------------------------
//
CContentHandler* CContentHandler::NewL()
    {
    CContentHandler* self = new (ELeave) CContentHandler;
    CleanupStack::PushL( self );
    self->ConstructL();
    CleanupStack::Pop( self );

    return self;
    }

// ---------------------------------------------------------------------------
// C++ destructor.
// ---------------------------------------------------------------------------
//
CContentHandler::~CContentHandler()
    {
    delete iMessageHandler;
    }

// ---------------------------------------------------------------------------
// From base class CNfcCH, NDEF message handling function.
// ---------------------------------------------------------------------------
//
void CContentHandler::HandleNdefMessage(
    TRequestStatus& aRequestStatus,
    CNdefMessage* aMessage )
    {
    if ( aMessage )
        {
        // Pass the message on to the CMessageHandler class for processing.
        // The handler will also take ownership of the message instance.
        iMessageHandler->HandleNdefMessage( aRequestStatus, aMessage );
        }
    }

// ---------------------------------------------------------------------------
// From base class CNfcCH, NDEF message handling cancellation function.
// ---------------------------------------------------------------------------
//
void CContentHandler::HandleNdefMessageCancel()
    {
    iMessageHandler->Cancel();
    }

// ---------------------------------------------------------------------------
// C++ constructor.
// ---------------------------------------------------------------------------
//
CContentHandler::CContentHandler() : CNfcCH()
    {
    // Empty implementation. This default implementation has no member
    // variables, so there is nothing to initialize on construction.
    }

// ---------------------------------------------------------------------------
// Symbian second phase constructor.
// ---------------------------------------------------------------------------
//
void CContentHandler::ConstructL()
    {
    iMessageHandler = CMessageHandler::NewL();
    }
